/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  width: 600px;
  min-height: 500px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  background: #ffffff;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 600px;
}

/* Header */
.header {
  padding: 16px;
  border-bottom: 1px solid #e1e5e9;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.current-page {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-url {
  font-size: 12px;
  opacity: 0.9;
  word-break: break-all;
  max-height: 36px;
  overflow: hidden;
}

.match-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  align-self: flex-start;
}

.match-status.active {
  background: #4caf50;
}

/* Navigation Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid #e1e5e9;
  background: #f8f9fa;
}

.tab-button {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: #666;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
}

.tab-button:hover {
  background: rgba(103, 126, 234, 0.1);
  color: #667eea;
}

.tab-button.active {
  color: #667eea;
  border-bottom-color: #667eea;
  background: white;
}

/* Tab Content */
.tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Actions */
.actions {
  padding: 16px;
  border-bottom: 1px solid #e1e5e9;
}

.element-rules-header {
  padding: 16px;
  border-bottom: 1px solid #e1e5e9;
  display: flex;
  gap: 12px;
  align-items: center;
}

.url-selector {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #5a6fd8;
}

.btn-secondary {
  background: #f8f9fa;
  color: #666;
  border: 1px solid #ddd;
}

.btn-secondary:hover:not(:disabled) {
  background: #e9ecef;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #c82333;
}

.btn-small {
  padding: 4px 8px;
  font-size: 12px;
}

.icon {
  font-size: 16px;
  line-height: 1;
}

/* Tables */
.table-container {
  flex: 1;
  overflow: auto;
  position: relative;
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.rules-table th {
  background: #f8f9fa;
  padding: 12px 8px;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 1px solid #e1e5e9;
  position: sticky;
  top: 0;
  z-index: 10;
}

.rules-table td {
  padding: 12px 8px;
  border-bottom: 1px solid #f1f3f4;
  vertical-align: middle;
}

.rules-table tbody tr:hover {
  background: #f8f9fa;
}

/* Table cell content */
.pattern-cell {
  max-width: 150px;
  word-break: break-all;
  font-family: monospace;
  font-size: 12px;
}

.selector-cell {
  max-width: 120px;
  word-break: break-all;
  font-family: monospace;
  font-size: 12px;
}

.status-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.status-enabled {
  background: #d4edda;
  color: #155724;
}

.status-disabled {
  background: #f8d7da;
  color: #721c24;
}

.action-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.action-hide {
  background: #fff3cd;
  color: #856404;
}

.action-show {
  background: #d1ecf1;
  color: #0c5460;
}

.matches-count {
  font-weight: 600;
  color: #667eea;
}

.matches-count.zero {
  color: #999;
}

.table-actions {
  display: flex;
  gap: 4px;
}

/* Empty State */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: #666;
  flex: 1;
}

.empty-state.show {
  display: flex;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 500;
}

.empty-subtitle {
  font-size: 14px !important;
  color: #999 !important;
  font-weight: normal !important;
}

/* Footer */
.footer {
  padding: 12px 16px;
  border-top: 1px solid #e1e5e9;
  background: #f8f9fa;
}

.stats {
  display: flex;
  justify-content: space-around;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-value {
  font-size: 18px;
  font-weight: 600;
  color: #667eea;
}

.stat-label {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-small {
  max-width: 400px;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e1e5e9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #f1f3f4;
  color: #666;
}

.modal-body {
  padding: 24px;
  max-height: 50vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid #e1e5e9;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #333;
}

.form-input, .form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.help-text {
  margin-top: 4px;
  font-size: 12px;
  color: #666;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 0 !important;
  font-weight: normal !important;
}

.checkbox-label input[type="checkbox"] {
  margin: 0;
}

.checkmark {
  display: inline-block;
}

/* Validation Status */
.validation-status {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  display: none;
}

.validation-status.show {
  display: block;
}

.validation-status.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.validation-status.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.validation-status.warning {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

/* Pattern Suggestions */
.pattern-suggestions {
  margin-top: 8px;
  display: none;
}

.pattern-suggestions.show {
  display: block;
}

.suggestion-item {
  padding: 8px 12px;
  border: 1px solid #e1e5e9;
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #f8f9fa;
}

.suggestion-item:hover {
  background: #e9ecef;
  border-color: #667eea;
}

.suggestion-pattern {
  font-family: monospace;
  font-size: 12px;
  color: #667eea;
  font-weight: 500;
}

.suggestion-description {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}

/* Element Testing */
.element-testing {
  margin: 16px 0;
  display: flex;
  gap: 8px;
}

/* URL Testing */
.url-testing {
  margin: 8px 0;
  display: flex;
  gap: 8px;
}

/* Loading */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 2000;
}

.loading-overlay.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  max-width: 300px;
}

.toast.show {
  transform: translateX(0);
}

.toast.success {
  background: #10b981;
}

.toast.error {
  background: #ef4444;
}

.toast.warning {
  background: #f59e0b;
}

.toast.info {
  background: #3b82f6;
}

/* Scrollbar */
.table-container::-webkit-scrollbar {
  width: 6px;
}

.table-container::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.table-container::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Responsive adjustments */
@media (max-height: 500px) {
  .modal-content {
    max-height: 90vh;
  }
  
  .modal-body {
    max-height: 40vh;
  }
}

/* Animation for rule updates */
.rules-table tbody tr.updating {
  background: rgba(102, 126, 234, 0.1) !important;
  transition: background-color 0.3s ease;
}

/* Highlight animation */
@keyframes highlight {
  0% { background: rgba(102, 126, 234, 0.3); }
  100% { background: transparent; }
}

.rules-table tbody tr.highlight {
  animation: highlight 1s ease;
}